package com.maochang.pojo.util;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;

@Data
@Slf4j
public class Result {
    private  int     code;  //响应逻辑码 0 代表查询成功  -1失败
    private  int     count; //条数
    private  String  msg;  //信息
    private  Object  data; //数据
    //静态的构造方法
    public   static Result success(Object data){
        Result result=new Result();
        result.setCode(0); //成功代表0
        result.setData(data);
        return result;
    };
    public   static Result successMsg(String msg){
        Result result=new Result();
        result.setCode(1); // 失败代表1
        result.setMsg(msg);
        return result;
    };
    public   static Result fail(String msg,Exception ex){
        Result result=new Result();
        result.setCode(-1); //成功代表0
        result.setMsg(msg);
        log.error(msg,ex);
        return result;
    };

}
